package com.twu.biblioteca;

import java.util.ArrayList;
import java.util.Iterator;

public class MovieShelf implements Iterable<Movie> {

    private ArrayList<Movie> movieShelf;

    public MovieShelf() {
        movieShelf = new ArrayList<Movie>();
    }

    public void addMovie(Movie movie) {
        movieShelf.add(movie);
    }

    public boolean has(Movie movie) {
        return movieShelf.contains(movie);
    }

    public String movieList() {
        String movieList = "";
        for (Movie movie : movieShelf) {
            movieList+= movie.record();
        }
        return movieList;
    }

    @Override
    public Iterator<Movie> iterator() {
        return movieShelf.iterator();
    }

    public String movieListHeader() {
        return String.format("%s\t\t\t\t\t%s\t\t%s\t\t\t%s\n","Movie","Year","Director","Rating");
    }
}
